/**
 ******************************************************************************
 * @file    icm20948.h
 * @author  Hsiang Hsu, livmee
 * @version V1.0.0
 * @date    2025-05-24
 * @brief   This file contains the headers of ICM20948 sensor.
 ******************************************************************************
 **/

#ifndef __ICM20948_H
#define __ICM20948_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

  /* Exported typedef -----------------------------------------------------------*/

  // ICM20948 数据结构体 [0:x, 1:y, 2:z]
  typedef struct
  {
    float acc[3];  // 加速度计数据 [0:x, 1:y, 2:z]
    float gyro[3]; // 陀螺仪数据 [0:x, 1:y, 2:z]
    float frame_count;   // 传感器ID
    float frame_diff;    // 帧差
  } ICM_Data_t;

  typedef struct
  {
    uint8_t others;
    uint8_t raw_data_0_rdy;
    uint8_t fifo_overflow;
    uint8_t fifo_watermark;
  } ICMInterruptStatusTypeDef;
  /* Exported define ------------------------------------------------------------*/
  /* Exported macro -------------------------------------------------------------*/
  /* Exported variables ---------------------------------------------------------*/
  /* Exported function prototypes -----------------------------------------------*/
  extern void ICM_Init(void);
  extern void SwapByteSPI2(uint8_t tx_data, uint8_t addr, uint8_t rwflag, uint8_t *rx_buf);
  extern void ICMGetDate(ICM_Data_t *pbuf);
  extern void ICMGetInterruptStatus(ICMInterruptStatusTypeDef *pbuf);
  extern uint16_t ICMGetFIFOData(uint8_t *pbuf); 
  extern __WEAK void ICMIntCallback(void);
  /* Exported functions ---------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif

/*-----------------------------------------------------------------------*/
